package utils;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Jennifer on 2018/4/14.
 */

public class FileUtils {

    public static String readJSONFromAsset(Context context, String fileName) {
        String json;
        try {
            AssetManager assets = context.getAssets();
            InputStream is = assets.open(fileName);
            int size = is.available();
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer, "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return null;
        }
        return json;
    }
}
